home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / crystal / cvend.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-01-12  |  1.6 KB  |  60 lines

  1. /* cvend.c
  2.  *    do stuff about the end of the game.
  3.  *************************************************************************/
  4.  
  5. #include    <stdio.h>
  6. #include    "cvmisc.h"
  7. #include    "cvobj.h"
  8. #include    "cvlocs.h"
  9. #include    "cvocab.h"
  10.  
  11. void
  12. getscore()
  13. {    register struct cvobj *object;
  14.     register struct hint *hint;
  15.  
  16.     score = 0;
  17.     /* get a first impression of how far the adventurer went */
  18.     if (RICK->prop > 0) score = 10;
  19.     if (DAM->prop > 0) score = 25;
  20.     if (dflag != 0) score = 30;
  21.     if (THRONE->prop == 0) score = 35;
  22.     mxscore = 35;
  23.  
  24.     /* tally treasures.  Full points if in barn and not broken.
  25.         2 points each for treasures seen. */
  26.     for (object = MINTRS; object < ENDTRS; ++object) {
  27.         register int value;
  28.         mxscore +=
  29.             (value = (object < RUG) ? 12 : ((object == RUG) ? 14 : 16));
  30.         if (object->prop >= 0) {
  31.             if (INBARN(object)
  32.                     && (object->prop == 0 || object == CUP))
  33.                 score += value;
  34.             else score += 2;
  35.         }
  36.     }
  37.  
  38.     /* Now look at how he finished, and how far he got.
  39.      *    "maxdie" and "numdie" tell us how well he survived.
  40.      *    "gaveup" says whether he is using "QUIT".
  41.      *    "dflag" will tell us if he ever got suitably deep into the cave.
  42.      *    "closing" still indicates whether he reached the endgame.
  43.      *    if he got as far as "CAVE CLOSED" then bonus will be false for
  44.      *        mundane exits.
  45.      */
  46.     score += (maxdie - numdie)*10; mxscore += maxdie * 10;
  47.     if (!scoring && !gaveup) score += 10; mxscore += 10;
  48.     if (closing) score += 30; mxscore += 30;
  49.     if (closed) {
  50.         score += 5;
  51.         if (bonus) score += 15;
  52.     }
  53.     mxscore += 20;
  54.  
  55.     for (hint = hints; hint->turns >= 0; ++hint) {
  56.         if (hint->hinted) score -= hint->points;
  57.     }
  58.     return;
  59. }
  60.